package array;

import java.util.ArrayList;

//堆
public class MyStack {
    private int size;
    private Long[] list;
    private int index = -1;

    public MyStack(int v) {
        size = v;
        list = new Long[size];
    }

    public void push(int j) {
        list[++index] = (long) j;
    }

    public Long pop() {
        return list[index--];
    }

    
    public long peek() {
        return list[index];
    }

    public boolean isEmpty() {
        return (index == -1);
    }

    public boolean isFull() {
        return (index == size - 1);
    }

    public static void main(String[] args) throws Exception {
        MyStack myStack = new MyStack(10);
        for (int i = 0; i < 10; i++) {
            myStack.push(i);
        }
        do {
            System.out.println("堆： " + myStack.pop());
        } while (!myStack.isEmpty());

        //队列
        ArrayList list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            list.add(i);
        }

        do {
            System.out.println("队列： " + list.get(0));
            list.remove(0);
    
        } while (!list.isEmpty());






    }

}
